#!/bin/bash

LOGFILE=drop_restore_point.txt
exec 3>&1
exec >> $LOGFILE

echo `date` "	drop_restore_point.sh is running"

export ORACLE_SID=CMTEST

RP=`sqlplus -s / as sysdba <<EOF
set heading off feedback off pagesize 0 trimspool on
set echo off
select nvl(max(name),'NO_RESTORE_POINT') from V\\$RESTORE_POINT where name = 'CM_RESTORE_POINT_1';
EOF
`
if [[ $RP == "CM_RESTORE_POINT_1" ]]; then

sqlplus -s '/ as sysdba' << EOF
drop restore point cm_restore_point_1;
EOF

if [ $? != 0 ]; then
  echo `date` "	Restore point wasn't dropped"
else
  echo `date` "	Restore point was dropped successfully"
fi
else
  echo `date` "	Nothing to do"
fi

exec 1>&3  3>&-
